import request from '@/utils/request'

interface Address {
  userid:string,
  name:string,
  tel:string,
  province:string,
  city:string,
  county:string,
  addressDetail:string,
  isDefault:boolean,
  [propName:string]:any
}
// 添加地址
export const add = (address:Address)=>{
  return request({
    url:'/address/add',
    method:"post",
    data:address
  })
}

// 更新地址 - 需要多一个addressid
export const update = (address:Address)=>{
  return request({
    url:'/address/update',
    method:"post",
    data:address
  })
}

// 删除地址
export const deleteOne = (addressid:string)=>{
  return request({
    url:'/address/delete',
    method:"post",
    data:{
      addressid
    }
  })
}

// 获取当前用户的所有地址列表
export const list = (userid:string)=>{
  return request({
    url:'/address/list',
    params:{
      userid
    }
  })

}